package com.oocl;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Date;

import com.oocl.constant.ProtocolType;
import com.oocl.pojo.Protocol;
import com.oocl.util.ResourceCloser;

public class Client1 {
    public static void main( String[] args ) throws ClassNotFoundException{
    	Socket socket = null;
    	ObjectOutputStream out = null;
    	ObjectInputStream in = null;
		try {
			socket = new Socket("127.0.0.1", 8888);
			out = new ObjectOutputStream(socket.getOutputStream());
			in = new ObjectInputStream(socket.getInputStream());
			Protocol protocol = new Protocol(ProtocolType.LOGIN, "mike", null, null, new Date());
			out.writeObject(protocol);
			out.flush();
			Protocol p = (Protocol) in.readObject();
			System.out.println(p);
			Thread.sleep(10000);
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			ResourceCloser.release(null, null, socket, null);
		}
    }
}
